package com.yilin.medical.views;

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yilin.medical.R;
import com.yilin.medical.utils.JxDeviceUtil;

public class JxTipDialog extends AlertDialog {
	private Button btnOk;
	private Button btnCancel;
	private TextView textMessage;
	private String message="真的要删除吗";
	private String strOk="是";
	private String strCancel="否";
	private RelativeLayout tipTrueBtnRl;
	private Button dialogTipBtn;
	private int type;
	private android.view.View.OnClickListener PositiveButton,
			NegativeButton;
	private Context context;
	public static boolean isShow;
	public JxTipDialog(Context context) {
		super(context, R.style.tip_dialog);
		this.context=context;
	}
	public JxTipDialog(Context context,int type) {
		super(context, R.style.tip_dialog);
		this.context=context;
		this.type=type;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.jx_zhagen_tip_dialog);
		RelativeLayout relative = (RelativeLayout) findViewById(R.id.tipDialog);
		relative.getLayoutParams().width =JxDeviceUtil.getScreenWidth(context);
		relative.getLayoutParams().height =JxDeviceUtil.getScreenHeight(context);
		tipTrueBtnRl=(RelativeLayout)findViewById(R.id.tipTrueBtnRl);
		btnCancel = (Button) findViewById(R.id.dialogTipBtnCancel);
		btnCancel.setText(strCancel);
		btnCancel.setOnClickListener(NegativeButton);
		btnOk = (Button) findViewById(R.id.dialogTipBtnOk);
		btnOk.setText(strOk);
		btnOk.setOnClickListener(PositiveButton);
		textMessage = (TextView) findViewById(R.id.dialogTipTextView);
		textMessage.setMovementMethod(ScrollingMovementMethod.getInstance());
		textMessage.setText(message);
		if(type==2){
			tipTrueBtnRl.setVisibility(View.GONE);
			dialogTipBtn=(Button)findViewById(R.id.dialogTipBtn);
			dialogTipBtn.setText(strOk);
			dialogTipBtn.setOnClickListener(PositiveButton);
			dialogTipBtn.setVisibility(View.VISIBLE);
		}
	}
	public void show(){
		super.show();
		isShow=true;
	}
	public void cancel(){
		super.cancel();
		isShow=false;
	}
	public void dismiss(){
		super.dismiss();
		isShow=false;
	}
	public void setStrCancel(String strCancel) {
		this.strCancel = strCancel;
	}
	
	public void setStrOk(String strOk) {
		this.strOk = strOk;
	}
	
	public void setMessage(String message) {
		this.message = message;
	}

	public void setPositiveButton(
			android.view.View.OnClickListener positiveButton) {
		PositiveButton = positiveButton;
	}

	public void setNegativeButton(android.view.View.OnClickListener negativeButton) {
		NegativeButton = negativeButton;
	}
}
